
var VIEW_COURSE = 'viewcourse';
var VIEW_SCORE = 'viewscore';
var VIEW_SCORE_DETAIL = 'viewscoredetail';
var VIEW_ENTER_SCORE = 'enterscore';
var VIEW_USER_SCORE = 'viewuserscore';
var VIEW_MAP = 'viewmap';
var VIEW_LOGIN = 'viewlogin'
var VIEW_HOLE = 'viewhole';

var VIEW_MAP_COURSE = 'mapcourse';
var VIEW_HOLE_DETAIL = 'holedetail'
var EDIT_HOLEDETAIL = 'edit_holedetail';
var PAGE_HISTORY = [];
var NO_HEADER_LIST = VIEW_COURSE + VIEW_ENTER_SCORE + VIEW_USER_SCORE + VIEW_MAP_COURSE;
function onback(){
	changePage(PAGE_HISTORY.pop());
}

function changePage(id,view){
	if(!id) return;
	var parentPage = $('div.page:visible');
	
	$('.page').hide();
	if(NO_HEADER_LIST.indexOf(id) == -1){
		$('#menu_back_container_id').show();
		check_element();
	} else {
		$('#menu_back_container_id').hide();
		check_element();
		
		if(view){
			$('.page').html('');
		}
	}
	
	var obj = $("#"+id);
	
	if(view){
		obj.html(view);
		if(parentPage.length > 0 && parentPage.attr('id') != id){
			PAGE_HISTORY.push(parentPage.attr('id'));
		}
	}
	obj.show();
	obj.css({"margin-left":"0%"});
}

function changeTitle(params){
	var page = $('#'+params['pageid']);
	if(params['uname']){
		page.find('.title-user-name').show();
		page.find('.title-user-name').text(params['uname']);
	}else{
		page.find('.title-user-name').hide();
	}
	if(params['cname']){
		page.find('.title-top').show();
		page.find('.title-top').text(params['cname']);
	} else {
		page.find('.title-top').hide();
	}
}

function check_element(){		
				$w_li = $('.elgg-bottom-menu li').filter(":visible").size();
				$('.elgg-bottom-menu li').css({'width':100/$w_li + '%'});
		};

		
		